// 动态路由
export const generateRoute = (menuList) => {
    let routes = []
    const deepList = (list) => {
        while (list.length) {
            let item = list.pop()
            // 父级目录
            if (item.parentId[0]) {
                routes.push({
                    name: item.component,
                    path: item.path,
                    meta: {
                        title: item.menuName
                    },
                    component: item.component
                })
            } else {
                // 子级菜单
                deepList(item.children)
            }
        }
    }
    deepList(menuList)
    return routes
}

// 菜单下至少有一个按钮，菜单才可以点击，不会跳转404页面

// 动态路由
// export const generateRoute = (menuList) => {
//     let routes = []
//     const deepList = (list) => {
//         while (list.length) {
//             let item = list.pop()
//             if (item.action) {
//                 routes.push({
//                     name: item.component,
//                     path: item.path,
//                     meta: {
//                         title: item.menuName
//                     },
//                     component: item.component
//                 })
//             }
//             if (item.children && !item.action) {
//                 deepList(item.children)
//             }
//         }
//     }
//     deepList(menuList)
//     return routes
// }